<?php

class PracticeTestAnswerModel extends CoreModel {

	function __construct()
	{
		parent::__construct();
	}

	public function returnTable()
	{
		return $this->PracticeTestAnswers;
	}

	public function getPracticeTestAnswer($id)
	{
		return $this->wpdb->get_results("SELECT * FROM ".$this->returnTable()." WHERE question_id=".$id);
	}

	public function checkAnserCorrectYesNo($id,$question)
	{
		$answer = $question == "yes" ? 1 : 0;
		$q = $this->wpdb->get_var("SELECT id FROM ".$this->returnTable()." WHERE id=".$id." AND is_answer=".$answer);
			return !empty($q) ? true : false;
	}

	public function checkAnswerCorrect($id)
	{
		$q = $this->wpdb->get_var("SELECT id FROM ".$this->returnTable()." WHERE id=".$id." AND is_answer=1");
		return !empty($q) ? true : false;
	}
}